/************************************************************************************
* CollectorView.h                                                                   *
*                                                                                   *
* Copyright (C) 2011 Varuna L Amachi                                                *
*                                                                                   *
* This program is free software; you can redistribute it and/or modify              *
* it under the terms of the GNU General Public License as published by              *
* the Free Software Foundation; either version 2 of the License, or any             *
* later version.                                                                    *
*                                                                                   *
* This program is distributed in the hope that it will be useful, but               *
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY        *
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for       *
* more details. You should have received a copy of the GNU General Public           *
* License along with this program; if not, write to the Free Software Foundation,   *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                       *
*                                                                                   *
*************************************************************************************/

#ifndef COLLECTORVIEW_H
#define COLLECTORVIEW_H

#include <QWidget>
#include <QSplitter>
#include <QTableView>
#include <QLineEdit>
#include <QComboBox>
#include <QAction>
#include <QCheckBox>
#include <QToolButton>
#include <QLabel>
#include <QRadioButton>
#include <QHash>
#include <QProgressBar>
#include <QLabel>
#include <QTreeView>


#include "interfaces/YContext.h"
#include "interfaces/IPlayerListener.h"
#include "interfaces/IPlaylistListener.h"
#include "common/YampComponent.h"
#include "FileSystemCollectionLoader.h"
#include "Collector.h"
#include "CollectorSortFilter.h"
#include "Types.h"
#include "widgets/SearchBox.h"
#include "widgets/StarWidget.h"


class CollectorView : public YampComponent,
                  public IPlayerListener,
                  public IPlaylistListener
{
    Q_OBJECT

    Collector* m_model;
    CollectorSortFilter* m_proxyModel;
    FileSystemCollectionLoader* m_loader;


//    QTableView* m_tableView;
    QTreeView *m_view;
    SearchBox* m_filter;
    QCheckBox* m_filterByArtist;
    QCheckBox* m_filterByAlbum;
    QCheckBox* m_filterByTitle;
    QToolButton* m_menuButton;
    QLabel* m_ruleOneLabel;
    QLabel* m_ruleTwoLabel;
    QRadioButton* m_andButton;
    QRadioButton* m_orButton;
    QLabel *m_status;
    QProgressBar *m_progress;

    QAction *m_actAddToPlaylist;
    QAction *m_actRemove;
    QAction *m_actAddDir;
    QAction *m_actAddFiles;
    QAction *m_actRescan;
    QAction *m_actAddArtist;
    QAction *m_actAddAlbum;


    void setupUi();
    void setupActions();
    void setupConnections();

public:
    static QString NAME;
    CollectorView(Yamp::YContext* context, QWidget* parent = 0);
    QString name();
    Collector* model();
    void contextMenuEvent(QContextMenuEvent *event);
    void playStarted(MediaItem* item);
    void finished(MediaItem* item);
    void selected(MediaItem* source);
    void playlistChanged();
    void playlistCleared();
    void ratingChanged(MediaItem *item, MediaRating rating);

private slots:

    void addDirectory();
    void addFiles();
    void orRuleActivated();
    void andRuleActivated();
    void onAddArtist();
    void onAddAlbum();
    void varifyActionValidity();

//    void setStatus(QString text);
//    void clearStatus();
    void itemLoadingStarted(int numItemsToLoad);
    void onCollectionDeletionComplete();

public slots:
    void finishedLoading(QList<CollectorItem*>* items);
    void filterChanged();
    void addToPlaylist();
    void addAndPlay();
    void removeFromCollection();
signals:

};
#endif // COLLECTOR_H
